package com.shkco.xbjcc.service.impl;

import com.shkco.exception.GlobalExceptionCode;
import com.shkco.utils.AssertUtil;
import com.shkco.xbjcc.domain.Login;
import com.shkco.xbjcc.dto.LoginDto;
import com.shkco.xbjcc.mapper.LoginMapper;
import com.shkco.xbjcc.service.ILoginService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 登录表 服务实现类
 * </p>
 *
 * @author whale
 * @since 2022-09-23
 */
@Service
public class LoginServiceImpl extends ServiceImpl<LoginMapper, Login> implements ILoginService {

    @Autowired
    private LoginMapper loginMapper;

    @Override
    public void common(LoginDto loginDto) {
        String username = loginDto.getUsername();
        String password = loginDto.getPassword();
        Login login = loginMapper.findByUsername(username);
        AssertUtil.isNotNull(login, GlobalExceptionCode.USER_INEXISTENCE);
        boolean b = password.equals(login.getPassword());
        AssertUtil.isTrue(b,GlobalExceptionCode.PASSWORD_MISTAKE);
    }
}
